package com.wqtz.chechai.view.fragments;

import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.wqtz.chechai.R;
import com.wqtz.chechai.adapter.TimeAdapter;
import com.wqtz.chechai.base.BaseFragment;
import com.wqtz.chechai.presenter.BasePresent;
import com.wqtz.chechai.utils.ToastUtils;
import com.wqtz.chechai.view.activities.TimeSelectActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2016/12/29 14:57
 */

public class TimeMonthFragment extends BaseFragment implements TimeAdapter.itemClickCallBack {
	@BindView(R.id.lv)
	ListView mLv;
	private int year;
	List<String> timelist;
	TimeAdapter mTimeAdapter;
	private String selectMonth;

	@Override
	public BasePresent createPresenter() {
		return null;
	}

	@Override
	protected int getContentView() {
		return R.layout.fragment_buycarmonth;
	}

	@Override
	protected void init(View view) {
		ButterKnife.bind(this, view);
		timelist = new ArrayList<>();
		for (int i= 1; i <=12 ; i++) {
			if(i<10){
				timelist.add(0+""+i+"月");
				}else {
				timelist.add(i+"月");
			}

		}

	}

	@Override
	protected void loadDatas() {
		mTimeAdapter = new TimeAdapter(R.layout.item_time_select);
		mTimeAdapter.addData(timelist);
		mLv.setAdapter(mTimeAdapter);
		mTimeAdapter.setCallBack(this);

	}



	@Override
	public void itemClick(int position) {
		selectMonth = timelist.get(position);
		//ToastUtils.show(getContext(),selectMonth,1000);
		TimeSelectActivity timeSelectActivity = (TimeSelectActivity) getActivity();
		timeSelectActivity.setMonth(selectMonth.substring(0,2));
	}
}
